package com.ruoyi.web.controller.chat;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.SysLoginService;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @author Tina
 * @version 1.0
 * @date 2021/6/20 19:36
 * @Desc 第三方API登录
 **/
@RestController
@RequestMapping("/auth/")
public class AuthController extends BaseController {
    @Autowired
    private SysLoginService loginService;

    @GetMapping("getAuthorize")
    public AjaxResult getAuthorize(String platform) {
        return AjaxResult.success();
    }

    /**
     * 登录方法
     *
     * @param loginBody 登录信息
     * @return 结果
     */
    @PostMapping("login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        LoginUser login = loginService.login(loginBody.getUsername(), loginBody.getPassword());
        return AjaxResult.success(login);
    }



}
